package com.peng.leetcode.sort;

import java.util.Arrays;

/**
 * LargestPerimeter
 *
 * @author: lupeng6
 * @create: 2020/12/10 17:00
 */
public class LargestPerimeter {

    static class Solution {
        public int largestPerimeter(int[] A) {
            Arrays.sort(A);

            for (int i = A.length - 1; i > 1 ; i--) {
                if (A[i] > (A[i - 1] + A[i - 2])) {
                    continue;
                }
                return A[i] + A[i - 1] + A[i - 2];
            }
            return 0;
        }
    }
}
